﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGsLightNode : OdGsEntityNode, OdSiEntity
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGsLightNode(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGsLightNode_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGsLightNode obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGsLightNode()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGsLightNode(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		HandleRef OdSiEntity.GetCPtr()
		{
			return new HandleRef(this, GlobalsPINVOKE.OdGsLightNode_OdSiEntity_GetCPtr(this.swigCPtr.Handle));
		}

		public new static OdGsLightNode cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsLightNode_cast(OdRxObject.getCPtr(pObj));
			OdGsLightNode result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsLightNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsLightNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsLightNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsLightNode_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsLightNode_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsLightNode_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdGsLightNode createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsLightNode_createObject();
			OdGsLightNode result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsLightNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsLightNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsLightNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGsLightNode(OdGsBaseModel pModel, OdGiDrawable pUnderlyingDrawable, bool bSetGsNode) : this(GlobalsPINVOKE.new_OdGsLightNode__SWIG_0(OdGsBaseModel.getCPtr(pModel), OdGiDrawable.getCPtr(pUnderlyingDrawable), bSetGsNode), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGsLightNode(OdGsBaseModel pModel, OdGiDrawable pUnderlyingDrawable) : this(GlobalsPINVOKE.new_OdGsLightNode__SWIG_1(OdGsBaseModel.getCPtr(pModel), OdGiDrawable.getCPtr(pUnderlyingDrawable)), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setModelTransform(OdGeMatrix3d xform)
		{
			GlobalsPINVOKE.OdGsLightNode_setModelTransform(this.swigCPtr, OdGeMatrix3d.getCPtr(xform));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGeMatrix3d modelTransform()
		{
			OdGeMatrix3d result = new OdGeMatrix3d(GlobalsPINVOKE.OdGsLightNode_modelTransform(this.swigCPtr), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGiDrawable.DrawableType drawableType()
		{
			OdGiDrawable.DrawableType result = (OdGiDrawable.DrawableType)GlobalsPINVOKE.OdGsLightNode_drawableType(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool isLight()
		{
			bool result = GlobalsPINVOKE.OdGsLightNode_isLight(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGiPointLightTraitsData pointLightTraitsData()
		{
			IntPtr intPtr = GlobalsPINVOKE.OdGsLightNode_pointLightTraitsData(this.swigCPtr);
			OdGiPointLightTraitsData result = (intPtr == IntPtr.Zero) ? null : new OdGiPointLightTraitsData(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGiSpotLightTraitsData spotLightTraitsData()
		{
			IntPtr intPtr = GlobalsPINVOKE.OdGsLightNode_spotLightTraitsData(this.swigCPtr);
			OdGiSpotLightTraitsData result = (intPtr == IntPtr.Zero) ? null : new OdGiSpotLightTraitsData(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGiDistantLightTraitsData distantLightTraitsData()
		{
			IntPtr intPtr = GlobalsPINVOKE.OdGsLightNode_distantLightTraitsData(this.swigCPtr);
			OdGiDistantLightTraitsData result = (intPtr == IntPtr.Zero) ? null : new OdGiDistantLightTraitsData(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGiWebLightTraitsData webLightTraitsData()
		{
			IntPtr intPtr = GlobalsPINVOKE.OdGsLightNode_webLightTraitsData(this.swigCPtr);
			OdGiWebLightTraitsData result = (intPtr == IntPtr.Zero) ? null : new OdGiWebLightTraitsData(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGiLightTraitsData lightTraitsData()
		{
			IntPtr intPtr = GlobalsPINVOKE.OdGsLightNode_lightTraitsData(this.swigCPtr);
			OdGiLightTraitsData result = (intPtr == IntPtr.Zero) ? null : new OdGiLightTraitsData(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void invalidate(OdGsContainerNode pParent, OdGsViewImpl pView, uint mask)
		{
			GlobalsPINVOKE.OdGsLightNode_invalidate(this.swigCPtr, OdGsContainerNode.getCPtr(pParent), OdGsViewImpl.getCPtr(pView), mask);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual bool saveClientNodeState(SWIGTYPE_p_OdGsFiler pFiler, OdGsBaseVectorizer pVectorizer)
		{
			bool result = GlobalsPINVOKE.OdGsLightNode_saveClientNodeState(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler), OdGsBaseVectorizer.getCPtr(pVectorizer));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool loadClientNodeState(SWIGTYPE_p_OdGsFiler pFiler, OdGsBaseVectorizer pVectorizer)
		{
			bool result = GlobalsPINVOKE.OdGsLightNode_loadClientNodeState(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler), OdGsBaseVectorizer.getCPtr(pVectorizer));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static bool drawableIsLight(OdGiDrawable.DrawableType drawableType)
		{
			bool result = GlobalsPINVOKE.OdGsLightNode_drawableIsLight((int)drawableType);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
